package cn.wolfcode.trip.base.domain;

import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
public class Region extends BaseDomain{

    public static final Integer STATE_NOMAL = 0; //普通
    public static final Integer STATE_COMMEND = 1; //推荐

    private String name;//区域名称

    private Region parent;//父区域对象

    private Integer state = STATE_NOMAL;//状态

    public Map toTreeView(){
        Map map = new HashMap();
        map.put("id",id);
        map.put("text",name);
        map.put("lazyLoad",true);
        //当被推荐才设置这个属性
        if(state==STATE_COMMEND){
            map.put("tags",new String[]{"推荐"});
        }
        //将它老爸装进去
        if(parent!=null){
            map.put("parentId",parent.getId());
            map.put("parentName",parent.getName());
        }
        return map ;
    }

}